import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/modules/application/special_operation/special_list/management_operation_page/more_working_person_page/more_working_person_controller.dart';

/// 人员列表
class MoreWorkingPersonPage extends StatelessWidget {
  MoreWorkingPersonPage({super.key});

  final controller = Get.put(MoreWorkingPersonController());

  /// 0：作业实施人 1：作业负责人 2：作业监护人 3:编制人 4：司索人 5:指挥人 6：用电人 7：安全交底人 8：接受交底人 9：验收人
  String _type(int? i) {
    switch (i) {
      case 0:
        return '作业实施人';
      case 1:
        return '作业负责人';
      case 2:
        return '作业监护人';
      case 3:
        return '编制人';
      case 4:
        return '司索人';
      case 5:
        return '指挥人';
      case 6:
        return '用电人';
      default:
        return '';
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        titleText: '人员列表',
      ),
      body: GetBuilder(
        init: controller,
        builder: (_) {
          return Container(
            padding: EdgeInsets.all(16.w),
            child: Column(
              children: [
                Container(
                  margin: EdgeInsets.all(12.w),
                    decoration: BoxDecoration(
                      color: const Color(0xffF7F7FB),
                      borderRadius: BorderRadius.all(Radius.circular(8.w)),
                      border: Border.all(width: 1.w, color: const Color(0xffEBEDF0)),
                    ),
                    child: TextField(
                        keyboardType: TextInputType.text,
                        textInputAction: TextInputAction.done,
                        maxLines: null,
                        onChanged: controller.search,
                        style: TextStyle(
                            color: const Color(0xFF262F38),
                            fontWeight: FontWeight.w400,
                            fontSize: 14.w),
                        decoration: InputDecoration(
                          counterText: '',
                          //防止适配不居中
                          isCollapsed: true,
                          border: const OutlineInputBorder(
                              borderSide: BorderSide.none),
                          contentPadding: EdgeInsets.symmetric(
                              vertical: 5.w, horizontal: 9.w),
                          hintText: '请输入关键词搜索',
                          hintStyle: TextStyle(
                              fontSize: 14.w,
                              fontWeight: FontWeight.w400,
                              color: const Color(0xffA0A7B5)),
                        ))),
                Expanded(
                  child: ListView.builder(
                    itemCount: controller.list.length,
                    itemBuilder: (context, index) {
                      return ListTile(
                        title: Text(controller.list[index].operatorUserName ?? ''),
                        subtitle: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text(_type(controller.list[index].operatorType)),
                            Text('证书编号：${controller.list[index].operatorCertificateNumber ?? ''}'),

                          ],
                        ),
                      );
                    },
                  ),
                ),
              ],
            ),
          );
        },
      ),
    );
  }
}
